<!DOCTYPE html>



  


<html class="theme-next muse use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />















  
  
  <link href="/blog/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/blog/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/blog/css/main.css?v=5.1.2" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="Hexo, NexT" />








  <link rel="shortcut icon" type="image/x-icon" href="/blog/favicon.ico?v=5.1.2" />






<meta name="description" content="1. JavaScript 数据类型Javascript 有六种基本数据类型（也就是简单数据类型），它们分别是：Undefined，Null，Boolean，Symbol，Number 和 String。还含有一种复杂数据类型，就是 Object（对象）。 注意 Undefined 和 Null 的区别，Undefined 类型只有一个值，就是 undefined，Null 类型也只有一个值，也就">
<meta property="og:type" content="article">
<meta property="og:title" content="JavaScript 之深浅拷贝™">
<meta property="og:url" content="http://xiezixi.oschina.io/2018/06/01/JS-深浅拷贝/index.html">
<meta property="og:site_name" content="个人博客">
<meta property="og:description" content="1. JavaScript 数据类型Javascript 有六种基本数据类型（也就是简单数据类型），它们分别是：Undefined，Null，Boolean，Symbol，Number 和 String。还含有一种复杂数据类型，就是 Object（对象）。 注意 Undefined 和 Null 的区别，Undefined 类型只有一个值，就是 undefined，Null 类型也只有一个值，也就">
<meta property="og:locale" content="zh-Hans">
<meta property="og:updated_time" content="2018-06-01T09:01:00.523Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="JavaScript 之深浅拷贝™">
<meta name="twitter:description" content="1. JavaScript 数据类型Javascript 有六种基本数据类型（也就是简单数据类型），它们分别是：Undefined，Null，Boolean，Symbol，Number 和 String。还含有一种复杂数据类型，就是 Object（对象）。 注意 Undefined 和 Null 的区别，Undefined 类型只有一个值，就是 undefined，Null 类型也只有一个值，也就">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/blog/',
    scheme: 'Muse',
    sidebar: {"position":"left","display":"post","offset":12,"offset_float":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: true,
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://xiezixi.oschina.io/2018/06/01/JS-深浅拷贝/"/>





  <title>JavaScript 之深浅拷贝™ | 个人博客</title>
  














</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">
  
  
    
  

  <div class="container sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/blog/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">个人博客</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">曦瓜皮</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/blog/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/blog/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/blog/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      

      
    </ul>
  

  
</nav>


 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://xiezixi.oschina.io/blog/2018/06/01/JS-深浅拷贝/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="曦瓜皮">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="个人博客">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">JavaScript 之深浅拷贝™</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-06-01T17:01:00+08:00">
                2018-06-01
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/JavaScript/" itemprop="url" rel="index">
                    <span itemprop="name">JavaScript</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <h2 id="1-JavaScript-数据类型"><a href="#1-JavaScript-数据类型" class="headerlink" title="1. JavaScript 数据类型"></a>1. JavaScript 数据类型</h2><p>Javascript 有六种基本数据类型（也就是简单数据类型），它们分别是：Undefined，Null，Boolean，Symbol，Number 和 String。还含有一种复杂数据类型，就是 Object（对象）。</p>
<p>注意 Undefined 和 Null 的区别，Undefined 类型只有一个值，就是 <code>undefined</code>，Null 类型也只有一个值，也就是 <code>null</code>。</p>
<ul>
<li><code>undefined</code> 实就是已声明未赋值的变量输出的结果</li>
<li><code>null</code> 空对象的引用</li>
</ul>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> a;</span><br><span class="line"><span class="built_in">console</span>.log(a); <span class="comment">// undefined</span></span><br><span class="line"><span class="built_in">console</span>.log(<span class="built_in">document</span>.getElementById(<span class="string">'a'</span>)); <span class="comment">// null</span></span><br></pre></td></tr></table></figure>
<h2 id="2-数据类型的区别"><a href="#2-数据类型的区别" class="headerlink" title="2. 数据类型的区别"></a>2. 数据类型的区别</h2><h3 id="2-1-简单数据类型"><a href="#2-1-简单数据类型" class="headerlink" title="2.1. 简单数据类型"></a>2.1. 简单数据类型</h3><p>它们值在占据了内存中固定大小的空间，并被保存在栈内存中。当一个变量向另一个变量复制基本类型的值，会创建这个值的一个副本，还有就是不能给基本数据类型的值添加属性。<br><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> a = <span class="number">1</span>;</span><br><span class="line"><span class="keyword">var</span> b = a;</span><br><span class="line">a.attr = <span class="string">'hello'</span>;</span><br><span class="line"><span class="built_in">console</span>.log(a.attr); <span class="comment">// undefined</span></span><br></pre></td></tr></table></figure></p>
<p>上面代码中 a 就是简单数据类型（Number），b 就是 a 的副本，它们两者都占有不同位置但相等的内存空间。</p>
<h3 id="2-2-复杂的数据类型"><a href="#2-2-复杂的数据类型" class="headerlink" title="2.2. 复杂的数据类型"></a>2.2. 复杂的数据类型</h3><p>复杂的数据类型即引用类型，它的值是对象，保存在堆内存中，包含引用类型值的变量实际上包含的并不是对象本身，而是一个指向该对象的指针。从一个变量向另一个变量复制引用类型的值，复制的其实是指针，因此两个变量最终都指向同一个对象。</p>
<h2 id="3-浅拷贝"><a href="#3-浅拷贝" class="headerlink" title="3. 浅拷贝"></a>3. 浅拷贝</h2><p>下面这段代码就是浅拷贝，有时候我们只是想备份数组，但是只是简单让它赋给一个变量，改变其中一个，另外一个就紧跟着改变，但很多时候这不是我们想要的。<br><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> obj = &#123;</span><br><span class="line">    name: <span class="string">'xiguapi'</span>,</span><br><span class="line">    age: <span class="number">23</span></span><br><span class="line">&#125;</span><br><span class="line"><span class="keyword">var</span> obj2 = obj;</span><br><span class="line">obj2[<span class="string">'age'</span>] = <span class="number">22</span>;</span><br><span class="line"><span class="built_in">console</span>.log(obj);<span class="comment">// &#123; name: 'xiguapi', age: 22 &#125;</span></span><br><span class="line"><span class="built_in">console</span>.log(obj2);<span class="comment">// &#123; name: 'xiguapi', age: 22 &#125;</span></span><br></pre></td></tr></table></figure></p>
<p>我们可以看到 obj 赋值给 obj2 后，当我们更改其中一个对象的属性值，两个对象都发生了改变，究其原因局势因为 obj 和 obj2 这两个变量都指向同一个指针，赋值只是复制了指针，所以当我们改变其中一个的值就会影响另外一个变量的值。</p>
<p>ES6 中的 <code>Object.assign()</code> 只是一级属性复制，比浅拷贝多深拷贝了一层而已。不能使用 <code>Object.assign()</code> 进行深拷贝。</p>
<h2 id="4-深拷贝"><a href="#4-深拷贝" class="headerlink" title="4. 深拷贝"></a>4. 深拷贝</h2><h3 id="4-1-基本类型数组"><a href="#4-1-基本类型数组" class="headerlink" title="4.1. 基本类型数组"></a>4.1. 基本类型数组</h3><p>对于<strong>基本数据类型数组</strong>我们可以使用 <code>slice()</code> 和 <code>concat()</code> 方法进行深拷贝。</p>
<h4 id="4-1-1-slice"><a href="#4-1-1-slice" class="headerlink" title="4.1.1. slice"></a>4.1.1. slice</h4><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> arr = [<span class="string">'xiguapi'</span>, <span class="number">22</span>];</span><br><span class="line"><span class="keyword">var</span> arrCopy = arr.slice();</span><br><span class="line">arrCopy[<span class="number">1</span>] = <span class="number">23</span>;</span><br><span class="line"><span class="built_in">console</span>.log(arr); <span class="comment">// [ 'xiguapi', 22 ]</span></span><br><span class="line"><span class="built_in">console</span>.log(arrCopy); <span class="comment">// [ 'xiguapi', 23 ]</span></span><br></pre></td></tr></table></figure>
<h4 id="4-1-2-concat"><a href="#4-1-2-concat" class="headerlink" title="4.1.2. concat"></a>4.1.2. concat</h4><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> arr = [<span class="string">'xiguapi'</span>, <span class="number">22</span>];</span><br><span class="line"><span class="keyword">var</span> arrCopy = arr.concat();</span><br><span class="line">arrCopy[<span class="number">0</span>] = <span class="string">'xiezixi'</span>;</span><br><span class="line"><span class="built_in">console</span>.log(arr); <span class="comment">// [ 'xiguapi', 22 ]</span></span><br><span class="line"><span class="built_in">console</span>.log(arrCopy); <span class="comment">// [ 'xiezixi', 22 ]</span></span><br></pre></td></tr></table></figure>
<h3 id="4-2-对象"><a href="#4-2-对象" class="headerlink" title="4.2. 对象"></a>4.2. 对象</h3><h4 id="4-2-1-封装方法"><a href="#4-2-1-封装方法" class="headerlink" title="4.2.1. 封装方法"></a>4.2.1. 封装方法</h4><p>对象我们可以定义一个封装好的方法来处理对象的深拷贝。<br><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> deepCopy = <span class="function"><span class="keyword">function</span> (<span class="params">source</span>) </span>&#123;</span><br><span class="line">    <span class="keyword">var</span> result = &#123;&#125;;</span><br><span class="line">    <span class="keyword">for</span> (<span class="keyword">var</span> key <span class="keyword">in</span> source) &#123;</span><br><span class="line">        <span class="keyword">if</span> (<span class="keyword">typeof</span> source[key] === <span class="string">'object'</span>) &#123;</span><br><span class="line">            result[key] = deepCopy(source[key])</span><br><span class="line">        &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">            result[key] = source[key]</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> result;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> obj = &#123;</span><br><span class="line">    name: <span class="string">'xiguapi'</span>,</span><br><span class="line">    age: <span class="number">23</span></span><br><span class="line">&#125;</span><br><span class="line"><span class="keyword">var</span> obj1 = deepCopy(obj);</span><br><span class="line">obj1[<span class="string">'age'</span>] = <span class="number">22</span>;</span><br><span class="line"><span class="built_in">console</span>.log(obj); <span class="comment">// &#123; name: 'xiguapi', age: 23 &#125;</span></span><br><span class="line"><span class="built_in">console</span>.log(obj1); <span class="comment">// &#123; name: 'xiguapi', age: 22 &#125;</span></span><br></pre></td></tr></table></figure>
<h4 id="4-2-2-JSON"><a href="#4-2-2-JSON" class="headerlink" title="4.2.2. JSON"></a>4.2.2. JSON</h4><p>如果数据中没有函数，可以直接用JSON来实现拷贝，如果有函数，就得用递归来实现深拷贝。需要兼容不同的浏览器并考虑速度的话，推荐使用 <code>JSON.parse(JSON.stringify())</code>。<br><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> obj = &#123;</span><br><span class="line">    name: <span class="string">'xiguapi'</span>,</span><br><span class="line">    age: <span class="number">23</span></span><br><span class="line">&#125;</span><br><span class="line"><span class="keyword">var</span> obj1 = <span class="built_in">JSON</span>.parse(<span class="built_in">JSON</span>.stringify(obj));</span><br><span class="line">obj1[<span class="string">'age'</span>] = <span class="number">22</span>;</span><br><span class="line"><span class="built_in">console</span>.log(obj); <span class="comment">// &#123; name: 'xiguapi', age: 23 &#125;</span></span><br><span class="line"><span class="built_in">console</span>.log(obj1); <span class="comment">// &#123; name: 'xiguapi', age: 22 &#125;</span></span><br></pre></td></tr></table></figure></p>
<h4 id="4-2-3-jQuery-clone"><a href="#4-2-3-jQuery-clone" class="headerlink" title="4.2.3. jQuery $.clone()"></a>4.2.3. jQuery $.clone()</h4><p>在 jQuery 中也有这么一个叫 <code>$.clone()</code> 的方法，可是它并不是用于一般的 JS 对象的深拷贝，而是用于 DOM 对象。</p>
<h4 id="4-2-4-jQuery-extend"><a href="#4-2-4-jQuery-extend" class="headerlink" title="4.2.4. jQuery $.extend()"></a>4.2.4. jQuery $.extend()</h4><p>可以通过 <code>$.extend()</code> 方法来完成深拷贝。值得庆幸的是，我们在 jQuery 中可以通过添加一个参数来实现递归 extend。调用 <code>$.extend(true, {}, ...)</code> 就可以实现深拷贝。<br><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> obj = &#123;</span><br><span class="line">       name: <span class="string">'xiguapi'</span>,</span><br><span class="line">       age: <span class="number">23</span></span><br><span class="line">   &#125;</span><br><span class="line">   <span class="keyword">var</span> obj1 = $.extend(<span class="literal">true</span>, &#123;&#125;, obj);</span><br><span class="line">   obj1[<span class="string">'age'</span>] = <span class="number">22</span>;</span><br><span class="line">   <span class="built_in">console</span>.log(obj); <span class="comment">// &#123; name: 'xiguapi', age: 23 &#125;</span></span><br><span class="line">   <span class="built_in">console</span>.log(obj1); <span class="comment">// &#123; name: 'xiguapi', age: 22 &#125;</span></span><br></pre></td></tr></table></figure></p>

      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/blog/2018/06/01/HTML5-ApplicationCache/" rel="next" title="HTML5 之 Application Cache™">
                <i class="fa fa-chevron-left"></i> HTML5 之 Application Cache™
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/blog/2018/06/01/JS-闭包/" rel="prev" title="JavaScript 之闭包™">
                JavaScript 之闭包™ <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/blog/images/avatar.jpg"
               alt="曦瓜皮" />
          <p class="site-author-name" itemprop="name">曦瓜皮</p>
           
              <p class="site-description motion-element" itemprop="description"></p>
          
        </div>
        <nav class="site-state motion-element">

          
            <div class="site-state-item site-state-posts">
              <a href="/blog/archives/">
                <span class="site-state-item-count">15</span>
                <span class="site-state-item-name">日志</span>
              </a>
            </div>
          

          
            
            
            <div class="site-state-item site-state-categories">
              <a href="/blog/categories/index.html">
                <span class="site-state-item-count">6</span>
                <span class="site-state-item-name">分类</span>
              </a>
            </div>
          

          

        </nav>

        

        <div class="links-of-author motion-element">
          
        </div>

        
        

        
        

        

      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-JavaScript-数据类型"><span class="nav-number">1.</span> <span class="nav-text">1. JavaScript 数据类型</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-数据类型的区别"><span class="nav-number">2.</span> <span class="nav-text">2. 数据类型的区别</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#2-1-简单数据类型"><span class="nav-number">2.1.</span> <span class="nav-text">2.1. 简单数据类型</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-2-复杂的数据类型"><span class="nav-number">2.2.</span> <span class="nav-text">2.2. 复杂的数据类型</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#3-浅拷贝"><span class="nav-number">3.</span> <span class="nav-text">3. 浅拷贝</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#4-深拷贝"><span class="nav-number">4.</span> <span class="nav-text">4. 深拷贝</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#4-1-基本类型数组"><span class="nav-number">4.1.</span> <span class="nav-text">4.1. 基本类型数组</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#4-1-1-slice"><span class="nav-number">4.1.1.</span> <span class="nav-text">4.1.1. slice</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#4-1-2-concat"><span class="nav-number">4.1.2.</span> <span class="nav-text">4.1.2. concat</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#4-2-对象"><span class="nav-number">4.2.</span> <span class="nav-text">4.2. 对象</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#4-2-1-封装方法"><span class="nav-number">4.2.1.</span> <span class="nav-text">4.2.1. 封装方法</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#4-2-2-JSON"><span class="nav-number">4.2.2.</span> <span class="nav-text">4.2.2. JSON</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#4-2-3-jQuery-clone"><span class="nav-number">4.2.3.</span> <span class="nav-text">4.2.3. jQuery $.clone()</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#4-2-4-jQuery-extend"><span class="nav-number">4.2.4.</span> <span class="nav-text">4.2.4. jQuery $.extend()</span></a></li></ol></li></ol></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2018</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">曦瓜皮</span>
</div>


<div class="powered-by">
  由 <a class="theme-link" href="https://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Muse
  </a>
</div>


        

        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  <script type="text/javascript" src="/blog/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/blog/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/blog/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/blog/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/blog/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/blog/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/blog/js/src/utils.js?v=5.1.2"></script>

  <script type="text/javascript" src="/blog/js/src/motion.js?v=5.1.2"></script>



  
  

  
  <script type="text/javascript" src="/blog/js/src/scrollspy.js?v=5.1.2"></script>
<script type="text/javascript" src="/blog/js/src/post-details.js?v=5.1.2"></script>



  


  <script type="text/javascript" src="/blog/js/src/bootstrap.js?v=5.1.2"></script>



  


  




	





  





  






  





  

  

  

  

  

  

</body>
</html>
